package com.java复习.练习二;

public class Triangle extends Ploygon {
    int base;  //三角形的底
    int height; //三角形的高

    private double hypotenuse; //斜边

    public int getBase() {
        return base;
    }

    public void setBase(int base) {
        this.base = base;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public double getHypotenuse() {
        return hypotenuse;
    }

    public void setHypotenuse(double hypotenuse) {
        this.hypotenuse = hypotenuse;
    }

    public Triangle(int base, int height) {
        super(3);
        this.base = base;
        this.height = height;
//        Triangle triangle1 = new Triangle(base,height);
//        int hypotenuse = (int) Math.sqrt(Math.pow(base,2)+Math.pow(height,2));
//        System.out.println("斜边为："+hypotenuse);
//        triangle1.setHypotenuse(hypotenuse);
//        System.out.println("在Triangle类的构造器中”");

    }

    @Override
    public String toString() {
        System.out.println("底为：" + base + "高为：" + height);
        return "Triangle{" +
                "base=" + base +
                ", height=" + height +
                '}';
    }


    public static double getArea(int base, int height) {
        int area; //面积
        area = (base * height) / 2;
        return area;
    }

}
